#!/usr/bin/python
# -*- coding: utf-8 -*-
from Tkinter import*
chtv = False
pol = False
posx = range(10,730,20)
i = 0
x = 0
def callback(event):
	global px,line,i,x
	if event.y % 5 == 1:
		event.y = event.y - 1
	if event.y % 5 == 2:
		event.y = event.y - 2
	if event.y % 5 == 3:
		event.y = event.y - 3
	if event.y % 5 == 4:
		event.y = event.y - 4
	if event.y % 5 == 0:
		if chtv == True:
			can.create_oval(posx[x],event.y-5,posx[x]+10,event.y+5,fill = "black")
			can.create_line(posx[x]+10,event.y,posx[x]+10,event.y-40)
			i = i + 1
			x = x + 1
		if pol == True:
			can.create_oval(posx[x],event.y-5,posx[x]+10,event.y+5)
			can.create_line(posx[x]+10,event.y,posx[x]+10,event.y-40)
			i = i + 2
			x = x + 1
		if i == 4 or i == 8 or i == 12 or i == 16 or i == 20 or i == 24:
			if posx[x] >= 730:
				pass
			else:
				can.create_line(posx[x]+10,line-10,posx[x]+10,line-50)
				x = x + 1
		if posx[x] >= 730:
			x = 0
def stan():
	global line
	i = 0
	line = 100
	while i < 5:
		can.create_line(5,line,735,line)
		line = line + 10
		i = i + 1
root = Tk()
can = Canvas(root,width = 740,height = 700)	
can.pack()
can.bind("<Button-1>", callback)
can.pack()
stan()
while True:
	inp = raw_input("введите длительность ноты: 2,  4 , 8: ")
	if inp == "4":
		chtv = True
		pol = False
	if inp == "2":
		pol = True
		chtv = False
	if inp == "q":
		break
root.mainloop()  
